<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use dosamigos\ckeditor\CKEditor;
use backend\widgets\Translit\TranslitWidget;
use backend\models\Page;
use kartik\select2\Select2;

/* @var $this yii\web\View */
/* @var $model backend\models\Page */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="create-form page-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'id_site')->dropDownList(
            \backend\models\Site::getList(),
            ['prompt' => 'Выберите сайт']
        ); 
    ?>

    <?= $form->field($model, 'is_draft')->radioList(
            [
                0 => 'Опубликован',
                1 => 'Черновик',
            ]
        )
    ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'alias')->widget(TranslitWidget::className(), [
            'clientOptions' => [
                'source' => 'page-title',
                'isNewRecord' => $model->isNewRecord,
            ],
        ]) 
    ?>

    <?= $form->field($model, 'description')->textarea(['rows' => 6])  ?>

    <?= $form->field($model, 'content')->widget(
        'trntv\aceeditor\AceEditor',
        [
            'mode'=>'html', // programing language mode. Default "html"
            'theme'=>'github', // editor theme. Default "github"
        ]
    )?>

    <?= $form->field($model, 'id_parent_page')->dropDownList(
            $pages,
            [
                'prompt' => 'Выбор родительской страницы',
            ]
        )->label('Родитель')
    ?>

    <?= $form->field($model, 'view')->radioList(
            [
                'blank' => 'Без разметки',
                'withleftmenu' => 'С левым меню',
                '3blankcolumn' => '3 колонки'
            ],
            [
                'item' => function($index,$label,$name,$checked,$value) {
                    return Html::radio(
                        $name,
                        $checked,
                        [
                            'label' => $label,
                            'value' => $value,
                            'labelOptions' => ['class' => 'template-icon template-icon_' . $value]
                        ]
                    );
                }
            ]
        )
    ?>

    <?= $form->field($model, 'is_hidden')->radioList(
        [
            Page::HIDDEN => 'Да',
            Page::VISIBLE => 'Нет',
        ])
    ?>

    <div class="form-group">
        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
